<template>
  <div >
    <!-- <div class="bg" :style="{ backgroundImage: `url(http://tu1.xingouka.com/Uploads%2FAttachment%2F2021-05-17%2F60a2811fed289.jpg)` }"></div> -->
    <!-- <webHeader2 props="" @listenToChildEvent="showMsgFromChild" @listenToChildEvent1="showMoreBaiduA"/> -->
    <div id="content">
      <div class="kyslogin-wrap">
        <div class="kyslogin-banner" style="background-color: #f9fafe;">
          <div id="banner-bg">
            <div class="kyslogin-inner">
              <div class="kyslogin-form">
                <div class="kyslogin-block">
                  <div class="kyslogin-title l-r-title">
                    <div class="l-r-txt">
                      <span ><nuxt-link to="/themes4" >登录</nuxt-link></span>
                      <em class="sep-long"></em>
                      <span ><nuxt-link style="color:#222" to="/register4" >注册</nuxt-link></span>
                    </div>

                  </div>
                  <div class="kyslogin-box">
                    <div style="display:block;" class="form">
                      <form class="layui-form" ref="form" :rules="formRules" :model="form" >
                        <div class="item m-container input-item item-fore1"
                             style="margin-top: 30px;">
                          <label for="loginname"
                                 class="icon-sprite kyslogin-account-icon"></label>
                          <input type="text" id="loginname" name="loginname" autocomplete="off"
                                 v-model="form.login"
                                 placeholder="请输入登录名" >
                        </div>
                        <div class="item m-container input-item item-fore2">
                          <label for="loginpwd" class="icon-sprite kyslogin-pwd-icon"></label>
                          <input type="password" id="loginpwd" name="password" autocomplete="off"
                                 v-model="form.password"
                                 placeholder="请输入密码"   >
                        </div>
                        <div class="item m-container input-item item-fore2">
                          <label for="loginpwdRepeat" class="icon-sprite kyslogin-pwd-icon"></label>
                          <input type="password" id="loginpwdRepeat" name="password" autocomplete="off"
                                 v-model="form.passwordRepeat"
                                 placeholder="再次输入密码"   >
                        </div>
                        <div class="item m-container input-item item-fore2">
                          <label for="username"
                                 class="icon-sprite kyslogin-account-icon"></label>
                          <input type="text" id="username" name="username" autocomplete="off"
                                 v-model="form.userName"
                                 placeholder="请输入用户名">
                        </div>
                        <div class="item m-container input-item item-fore2">
                          <label for="loginname"
                                 class="icon-sprite kyslogin-account-icon"></label>
                          <input type="text" id="qq" name="qq" autocomplete="off"
                                 v-model="form.qq"
                                 placeholder="请输入联系QQ">
                        </div>
                        <div class="item m-container input-item item-fore2">
                          <label for="loginname" class="icon-sprite kyslogin-pwd-icon"></label>
                          <input type="password" id="trade_password" name="trade_password"
                                 v-model="form.parentID"
                                 autocomplete="off" placeholder="上级编号(没有可不填)">
                        </div>
                        <div class="item item-fore4">
                          <div class="fr kyslogin-forget-pw-safe">
                                                    <span class="forget-pw-safe">
                                                        <nuxt-link to="/forget4"
                                                           target="_blank">忘记密码</nuxt-link></span>
                          </div>
                        </div>
                        <div class="item m-container item-fore5">
                          <div class="kyslogin-btn">
                            <a lay-submit="" lay-filter="login" class="btn-img btn-entry" id="loginsubmit"  @click="doRegister">立即注册</a>
                          </div>
                        </div>
                      </form>
                    </div>
                  </div>
                </div>

                <div class="kyslogin-coagent">
                  <div class="coagent-title">
                    第三方快捷登录
                  </div>
                  <div class="coagent-list">
                    <div class="kyslogin-coagent-qq coagent-item ">
                      <a :href="pageData.qq" target="_blank" ref="nofollow">
                        <i class="icon-sprite qq-icon"></i>
                        <span>QQ登录</span>
                      </a>
                    </div>
                    <div class="kyslogin-coagent-wx coagent-item">
                      <a :href="pageData.wx" target="_blank" ref="nofollow">
                        <i class="icon-sprite wx-icon"></i>
                        <span>微信登录</span>
                      </a>
                    </div>
                  </div>
                </div>
              </div>
                  </div>
                </div>
            </div>
          </div>
        </div>
      <!--    <qplayer :url="systemStyle.backMusic" />-->
      <!--    <qqservice :qq-link="systemStyle.qqLink" :qun-link="systemStyle.qunLink" />-->

    <webFooter2 />
  </div>

</template>

<script>
import { mapState } from 'vuex'
import webFooter2 from '../webFooter4'
import qqservice from './qqservice'
import fixupMixin from '@/mixins/fixup'
import bgdefImg from '@/assets/bg_def.jpg'

export default {
  components: {
    webFooter2,
    qqservice
  },
  // mixins: [fixupMixin],
  props: {
    pageData: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      form: {
        login: '',
        userName: '',
        phoneNum: '',
        password: '',
        passwordRepeat: '',
        parentID: '',
        qq: ''
      },
      formRules: {
        login: [
          { required: true, message: '请输入登录名', trigger: 'blur' },
          { min: 4, max: 20, message: '长度在 4 到 20 个字符', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '请输入密码', trigger: 'blur' },
          { min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' }
        ],
        passwordRepeat: [
          { required: true, message: '请再次输入密码', trigger: 'blur' },
          { min: 6, max: 20, message: '长度在 6 到 20 个字符', trigger: 'blur' }
        ],
        userName: [
          { required: true, message: '请输入用户名', trigger: 'blur' },
          { min: 4, max: 20, message: '长度在 4 到 20 个字符', trigger: 'blur' }
        ]},
      bgdefImg,
      qqLink1: "",
      qqLink2: "http://wpa.qq.com/msgrd?v=3&uin=1846189021&site=qq&menu=yes",
      qqLink3: "http://wpa.qq.com/msgrd?v=3&uin=1846189021&site=qq&menu=yes"
    }
  },
  computed: {
    ...mapState({
      site: (state) => state.site,
      systemStyle: (state) => state.systemStyle
    })
  },
  mounted() {
    console.log('pageData', this.pageData)
    this.qqLink1 = "http://wpa.qq.com/msgrd?v=3&uin=" + this.pageData.contact.frontWorkQQ + "&site=qq&menu=yes"
    this.qqLink2 = "http://wpa.qq.com/msgrd?v=3&uin=" + this.pageData.contact.frontComplaintQQ + "&site=qq&menu=yes"
    this.qqLink3 = "http://wpa.qq.com/msgrd?v=3&uin=" + this.pageData.contact.frontServiceQQ + "&site=qq&menu=yes"
    if (this.systemStyle.isQun == 1) {
      const iframe = document.createElement('iframe')
      iframe.src = this.systemStyle.qunLink + '?' + new Date().getTime()
      iframe.id = 'iframe'
      iframe.style = 'display:none'
      document.body.appendChild(iframe)
      setTimeout(function () {
        const a = document.getElementById('iframe')
        document.body.removeChild(a)
      }, 60000)
    }
    window.addEventListener('keydown', (event) => {
      const e = event || window.event
      if (e.keyCode === 13) {
        this.doLogin()
      }
    })
  },
  methods: {
    showMoreBaiduA(e){
      console.log(e);
    },

    showMsgFromChild(d){
      const h = this.$createElement;
      let This = this;

      setTimeout(function(){
        document.getElementsByClassName('el-message-box__content')[0].innerHTML = "";
        document.getElementsByClassName('el-message-box__content')[0].appendChild(This.$refs.mesBoxCon);
      },50)
      this.$msgbox({
        title: '注册',
        message: h("div",null,""),
        showCancelButton: false,
        showConfirmButton: false,
        beforeClose: (action, instance, done) => {
          setTimeout(function(){This.$refs.innerMes.appendChild(This.$refs.mesBoxCon)},100)

          done();
        }
      }).catch(()=>{
        new Error("弹窗错误")
      });
    },
    async doRegister() {
      if (this.form.password !== this.form.passwordRepeat) {
        return this.$message.error('两次输入的密码不一致')
      }
      const res = await this.$axios.post('/user/user/register', null, {
        params: this.form,
        tokenUpdate: true
      })
      // alert("111");
      console.log("res"+ JSON.stringify(res));
      if (res.code === 1001) {
        this.$message.success('注册成功，即将跳转')
        if(this.systemStyle.goPage == null || this.systemStyle.goPage == 0){
          this.$router.push('/category-list4')
        }else{
          this.$router.push('/category-list4')
        }
      }
    }
  },
    // location.href = '/main'
}
</script>

<style lang="scss">
@import 'assets/style/icon.css';


#content .kyslogin-wrap {
  margin-top: 0;
}
.kyslogin-wrap {
  position: relative;
  height: 772px;
  z-index: 5;
}
.kyslogin-wrap .kyslogin-banner {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 772px;
}
.kyslogin-wrap .kyslogin-banner #banner-bg {
  width: 100%;
  height: 842px;
  background: url(https://ae04.alicdn.com/kf/U2e92fed8d98646e9926d026918ff024bc.jpg) top center no-repeat;
  margin-top: -70px;
}
.kyslogin-inner {
  width: 1200px;
  margin: 0px auto;
  padding-top: 150px;
  height: 673px;
}
.kyslogin-inner .kyslogin-form {
  width: 420px;
  height: auto;
  float: right;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 2px 8px -2px rgba(53, 53, 53, .5);
  box-shadow: 0px 6px 68px 0px rgba(0, 0, 0, 0.1);
  position: relative;
}
.kyslogin-inner .kyslogin-block,
.kyslogin-inner .zhw-qrcode-login {
  padding: 32px 40px;
  height: auto;
}
.icon-sprite {
  position: relative;
}

/* 头部 */
.l-r-title {
  height: 24px;
}

.l-r-title .l-r-txt {
  line-height: 1;
  float: left;
}
.l-r-title .l-r-txt span,
.l-r-title .l-r-txt span a {
  display: inline-block;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  transition: color .3s;
}
.l-r-title .l-r-txt span:hover,
.l-r-title .l-r-txt span:hover a {
  color: #222;
}
.l-r-title .l-r-txt span.cur {
  color: #222;
}
.l-r-title .l-r-txt em.sep-long {
  display: inline-block;
  height: 15px;
  border-left: 1px solid #c0c0c0;
  margin: 0 28px;
}
.input-item {
  width: 338px;
  height: 42px;
  border: 1px solid #E8E8E8;
  margin-bottom: 16px;
  position: relative;
}

.input-item input {
  border: 0;
  outline: none;
  width: 258px;
  height: 40px;
  padding: 0 40px;
}

.input-item.item-fore1 .clear-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 15px;
  height: 15px;
  line-height: 13px;
  text-align: center;
  border-radius: 50%;
  color: #fff;
  background: #787878;
  cursor: pointer;
  font-size: 13px;
}

/* label 图标 */

.input-item label {
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 42px;
}
.kyslogin-account-icon.icon-sprite::after {
  top: 14px;
  left: 14px;
  width: 11px;
  height: 14px;
  text-align: center;
  background-position: -15px -13px;
  transition: all .3s;
}
.input-focus .kyslogin-account-icon.icon-sprite::after {
  background-position: -33px -13px;
}

.kyslogin-pwd-icon.icon-sprite::after,
.reg-pwd-icon.icon-sprite::after {
  top: 14px;
  left: 14px;
  width: 13px;
  height: 14px;
  text-align: center;
  background-position: -54px -14px;
  transition: all .3s;
}
.input-focus .kyslogin-pwd-icon.icon-sprite::after,
.input-focus .reg-pwd-icon.icon-sprite::after {
  background-position: -72px -14px;
}

.kyslogin-verify-icon.icon-sprite::after,
.reg-verify-icon.icon-sprite::after {
  top: 17px;
  left: 14px;
  width: 15px;
  height: 10px;
  text-align: center;
  background-position: -141px -17px;
  transition: all .3s;
}
.input-focus .kyslogin-verify-icon.icon-sprite::after,
.input-focus .reg-verify-icon.icon-sprite::after {
  background-position: -164px -17px;
}


.item-fore4 {
  margin-top: -10px;
  height: 10px;
  color: #888;
}






.item-fore4 .kyslogin-forget-pw-safe a {
  color: #888;
  font-size: 12px;
  transition: color .3s;
}
.item-fore4 .kyslogin-forget-pw-safe a:hover {
  color: #fc3737;
}


/* 登录按钮 */
.form .item-fore5 {
  margin: 0 auto;
  height: 44px;
  position: relative;
  text-align: center;
  margin-top: 38px
}
.form .item-fore5 .btn-img {
  display: block;
  width: 340px;
  background: #fc3737;
  height: 44px;
  line-height: 44px;
  color: #fff;
  font-size: 18px;
  font-family: 'Microsoft YaHei';
  border-radius: 4px;
  transition: all .3s;
  cursor: pointer;
}
.form .item-fore5 .btn-img:hover {
  box-shadow:0px 3px 20px 0px rgba(252, 55, 55, 0.68);
}

/* 第三方登录 */
.kyslogin-coagent {
  margin-top: -2px;
  margin-bottom: 32px;
  text-align: center;
}

.kyslogin-coagent .coagent-title {
  position: relative;
  height: 20px;
  line-height: 20px;
  font-size: 14px;
  color: #888;
  margin-bottom: 10px;
}
.coagent-title::after,
.coagent-title::before {
  content: '';
  position: absolute;
  top: 9px;
  left: 40px;
  width: 70px;
  height: 1px;
  background: #d8d8d8;
}
.coagent-title::before {
  left: auto;
  right: 40px;
}
.coagent-list .coagent-item {
  display: inline-block;
  margin: 15px;
  margin-top: 8px;
  margin-bottom: 0;
  cursor: pointer;
}

.coagent-list .coagent-item .icon-sprite {
  display: block;
  width: 41px;
  height: 41px;
  margin: 0 auto;
}
.coagent-list .coagent-item .icon-sprite::after,
.coagent-list .coagent-item .wx-icon.icon-sprite::after {
  width: 41px;
  height: 41px;
  top: 0;
  left: 0;
  border-radius: 50%;
  background-position: -66px -40px;
}

.coagent-list .coagent-item .wx-icon.icon-sprite::after {
  background-position: -117px -40px;
}


.coagent-list .coagent-item:hover .icon-sprite::after,
.coagent-list .coagent-item:hover .wx-icon.icon-sprite::after {
  height: 48px;
  background-position: -168px -40px;
}

.coagent-list .coagent-item:hover .wx-icon.icon-sprite::after {
  background-position: -219px -40px;
}
.icon-sprite {
  position: relative;
}

.coagent-list .coagent-item span {
  display: block;
  color: #888;
  font-size: 12px;
  margin-top: 10px;
}
.item-fore4 .kyslogin-forget-pw-safe a {
  color: #888;
  font-size: 12px;
  transition: color .3s;
}
.item-fore4 .kyslogin-forget-pw-safe a:hover {
  color: #fc3737;
}
.fr{float:right;display:inline;}

@media screen and (max-width: 800px) {
  .kyslogin-inner {
    width: 100% !important;
    .kyslogin-form {
      width: 100% !important;
    }
    .kyslogin-block {
      display: flex;
      flex-direction: column;
    }

  }
  .input-item {
    width: 100% !important;
  }
  .fr {
    float: unset !important;
  }
  .form .item-fore5 .btn-img {
    width: 100% !important;
  }

  .Top {
    display: none;
  }
  .common-fluid {
    display: none;
  }
}
</style>
<style lang="scss">

</style>
